<?php
namespace home;
use controllers\BaseControllers;
//Home模块基础控制器
class Home extends BaseControllers{
    //重写Home构造方法，重写了之后所就按照最近的继承控制器为准
    public function __construct(){
        \Twig_Autoloader::register();
        $loader = new \Twig_Loader_Filesystem(TEMPDIR."/app/view/".TEMPNAME);
        $this->twig = new \Twig_Environment($loader);
    }

    //重写父类的display方法   初始化数据[url，目录地址]
    protected function display($template){
        //根目录url
        $url = getCurUrl();
        //前台url
        $home_url = $url . '/resource/'.TEMPNAME;
        $this->assign('url',$url);
        $this->assign('home_url',$home_url);
        echo $this->twig->render($template.'.html',$this->data);
    }
}